import java.util.PriorityQueue;

class Solution {
    public int halveArray(int[] nums) {
        double sum=0;
        PriorityQueue<Double> heap=new PriorityQueue<>((a,b) -> b.compareTo(a));
        for (int i = 0; i < nums.length; i++) {
            heap.offer((double)nums[i]);
            sum+=nums[i];
        }
        int count=0;
        sum/=2;
        while(sum>0){
            double t=heap.poll();
            t/=2;
            sum-=t;
            count++;
            heap.offer(t);
        }
        return count;
    }
}